package reflection;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Excercise {
	public static void main(String[] args) {
		BufferedInputStream obj1 = new BufferedInputStream(null);
		
		Class c1 = obj1.getClass();
		System.out.println("Supper: " + c1.getSuperclass());
		System.out.println("Interface: " + c1.getInterfaces());
		System.out.println("Methods: " + c1.getMethods());
		
		Field[] fs = c1.getFields();
		for(Field f: fs) {
			System.out.println("Field name: " + f.getName());
		}
		
		Method[] ms = c1.getMethods();
		for(Method m: ms) {
			System.out.println("Method name: " + m.getName());
			System.out.println("Full description: " + m.toString());
			
			Class[] cls = m.getParameterTypes();
			for(Class cl: cls) {
				System.out.println("Parameter: " + cl.getName());
			}
		}
		
		System.out.println();
		
		try {
			DataInputStream obj2 = new DataInputStream(new FileInputStream("a.txt"));
			
			Class c2 = obj2.getClass();
			System.out.println("Supper: " + c2.getSuperclass());
			System.out.println("Interface: " + c2.getInterfaces());
			System.out.println("Methods: " + c2.getMethods());
			
			Field[] fs2 = c2.getFields();
			for(Field f: fs2) {
				System.out.println("Field name: " + f.getName());
			}
			
			Method[] ms2 = c2.getMethods();
			for(Method m: ms2) {
				System.out.println("Method name: " + m.getName());
				System.out.println("Full Description: " + m.toString());
				
				Class[] cls = m.getParameterTypes();
				for(Class cl: cls) {
					System.out.println("Parameter: " + cl.getName());
				}
			}
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

}
